<html>

<head>
    <meta charset="utf8">
</head>

<body>

    <script>
        // 这是第三方授权跳转页面
        // 用于非weichat.juzhen.net 域名下的授权操作

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        function tpaToLocal(url) {
            // var origin = 'http://' + GetQueryString('origin').replace(/\*/g, '/') + 'index.html';
            var origin = 'http://' + GetQueryString('origin').replace(/\*/g, '/');
            var params = '';
            // 将所有参数全部转移到授权请求地址
            if (url.indexOf('?') >= 0) {
                var arr1 = url.split('?');
                var arr2 = arr1[1].split('&');  // eg: aa=sdf bb=435

                var num = 0;
                for (var i = 0; i < arr2.length; i++) {
                    if (arr2[i].indexOf('origin') < 0) { // 过滤origin
                        if (num === 0) {
                            params = params + '?' + arr2[i];
                        } else {
                            params = params + '&' + arr2[i];
                        }
                        num++;
                    }

                }
            }

            return (origin + params);
        }

        var toUri = tpaToLocal(location.href);
        location.href = toUri;
    </script>
</body>

</html>